"""
@Author : 合肥一元数智教育科技有限公司
@Date :  2025/5/29 8:45
@Description : 
打开模式
r  w   a   +   t    b
"""

"""
with open('a.txt', 'r+', encoding='utf-8') as f:
    # line = f.readline()
    # print(line)
    # r+  写出数据    数据写出的位置需要看指针所在位置  如果指针后有数据则会覆盖
    f.write('hellojava')  # r  io.UnsupportedOperation: not writable
"""

"""
#  w  清空文件写入新内容
with open('a.txt', 'w+', encoding='utf-8') as f:
    f.write('hellojava')
    # 移动指针
    f.seek(0)
    # 读取数据  w+
    line = f.readline()  # w  io.UnsupportedOperation: not readable
    print(line)
"""
# append
with open('a.txt', 'a+', encoding='utf-8') as f:
    # f.write('hellopython')
    f.seek(0)
    # a +
    line = f.readline()  # a   io.UnsupportedOperation: not readable
    print(line)
